// TODO 将创建单位封装到 UnitUtil 中
// 从 InitFunction 中移除
library UnitUtil initializer init requires InitFunction

    // 获取指定单位的模型字符串
    function getUnitModelString takes unit u returns string
        local string sV = YDWEGetObjectPropertyString(YDWE_OBJECT_TYPE_UNIT, GetUnitTypeId(u), "file")
        if SubString(sV, StringLength(sV)-4, StringLength(sV)-1) != ".md" then
            set sV = sV + ".mdl"
        endif
        return sV
    endfunction

    // 获取指定单位类型的模型
    function getUnitTypeModelString takes integer unitType returns string
        local string sV = YDWEGetObjectPropertyString(YDWE_OBJECT_TYPE_UNIT, unitType, "file")
        if SubString(sV, StringLength(sV)-4, StringLength(sV)-1) != ".md" then
            set sV = sV + ".mdl"
        endif
        return sV
    endfunction

    private function init takes nothing returns nothing
        
    endfunction
endlibrary



